import {Component, ElementRef, OnInit, ViewChild} from '@angular/core';
import {debounceTime, distinctUntilChanged, fromEvent, map, Observable, of, scan, switchMap, throttleTime, timer} from "rxjs";
import { QueueScheduler } from 'rxjs/internal/scheduler/QueueScheduler';

@Component({
  selector: 'app-myrxjs',
  templateUrl: './myrxjs.component.html',
  styles: [
  ]
})
export class MyrxjsComponent implements OnInit {
  text: string = '';
  list: string[] = [];
  @ViewChild('addBtn') addBtn : ElementRef<HTMLParagraphElement> | undefined
  constructor() { }

  ngOnInit(): void {
    // 一段时间只会出现一次
    // const button : any = document.querySelector('button');
    // fromEvent(button, 'click').pipe(throttleTime(1000), scan(count => count + 1, 0))
    //     .subscribe(count => console.log(`Clicked ${count} times`));
    // 一段时间只会出现一次
    // let addBtn : any = document.querySelector('#addBtn');
    // fromEvent(addBtn, "click")
    //     .pipe(throttleTime(2000))
    //     .subscribe(x => {
    //           // console.log(x)
    //           this.list.push(this.text);
    //     })
  }

  add() {

  }
}
